<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script src="/html/js/layui.js"></script>
    <script src="/html/js/util.js"></script>
    <link rel="stylesheet" href="/html/js/css/layui.css" media="all">
    <title>管理员订单处理</title>
</head>
<script>
    let orderId = 0;
    window.onload = function () {
        orderId = getQuery("orderId");
        showOrderInfo();

    }

    async function showOrderInfo() {
        let info = await ajaxGet("/order/findOrderInfo", {orderId});
        $("orderId").innerHTML = info.orderId;
        $("orderPeo").innerHTML = info.orderPeo;
        $("orderLocation").innerHTML = info.orderLocation;
        $("orderTel").innerHTML = info.orderTel;
        $("orderDate").innerHTML = info.orderDate;
        $("orderAllPrice").innerHTML = info.orderAllPrice;
        $("orderStatue").innerHTML = info.orderStatue;
        let list = info.infoList;
        let str = "";
        for (let i = 0; i < list.length; i++) {
            let obj = list[i];
            str += `<tr>
                <td>${obj.productBean.productId}</td>
                <td>${obj.productBean.productName}</td>
                <td>${obj.productBean.productPrice}</td>
                <td>${obj.num}</td>
                </tr>`;
        }
        $("bodys").innerHTML = str;
    }

    //处理订单
    async function sendOrder() {
        let obj = await ajaxGet("/order/updatePro", {orderId: orderId});
        if (obj == "ok") {
            location.href = "/html/manager/pressOrder.html";
        } else {
            alert("处理失败");
        }
    }


</script>


<body style="padding-left: 50px;padding-top: 50px">
<div>
    订单号: <span id="orderId"></span>
    <br>
    收货人: <span id="orderPeo"></span>
    <br>
    送货地址: <span id="orderLocation"></span>
    <br>
    收货人电话: <span id="orderTel"></span>
    <br>
    下单时间: <span id="orderDate"></span>
    <br>
    订单总价: <span id="orderAllPrice"></span>
    <br>
    订单状态: <span id="orderStatue"></span>
</div>
<div>
    <h2>订单明细</h2>
</div>
<div style="width: 50%">
    <table class="layui-table">
        <colgroup>
            <col width="150">
            <col width="200">
            <col>
        </colgroup>
        <thead>
        <tr>
            <th>商品编号</th>
            <th>商品名称</th>
            <th>单价</th>
            <th>商品购买数量</th>
        </tr>
        </thead>
        <tbody id="bodys">
        </tbody>
    </table>
    <button type="button" class="layui-btn"><a href="/html/manager/pressOrder.html">返回</a></button>
    <button type="button" class="layui-btn"><a href="javascript:sendOrder()">发货</a></button>
</div>


</body>
</html>